package application;
	
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import util.PropertyUtil;
import util.RegisterUtil;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;


public class Main extends Application {
	@Override
	public void start(Stage primaryStage) {
		try {
			if(PropertyUtil.getKeyValue("code")==null||PropertyUtil.getKeyValue("code").equals("")
					||!PropertyUtil.getKeyValue("code").equals(RegisterUtil.getRegistrationCode())){
				RegisterForm.showAlertDialog();
			}else{
			Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("view/QKmed.fxml"));
			Scene scene = new Scene(root);
			primaryStage.setTitle("文本转换器");
			primaryStage.setResizable(false);
			primaryStage.getIcons().add(new Image("/images/icon.png"));
			scene.getStylesheets().add(getClass().getClassLoader().getResource("css/application.css").toExternalForm());
			primaryStage.setScene(scene);
			primaryStage.show();
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
		
		primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
			@Override
			public void handle(WindowEvent event) {
				System.exit(0);
			}
		});
	}
	
	public static void main(String[] args) {
		launch(args);
	}
}
